//----------------------------------------------------------------------
//
//  LJUDDelphi.pas
//
//  Delphi wrapper interface for the labjackud dll driver.  Please
//  refer to the labjackud.h c header file and the UE9/U3 User Guide for
//  documentation on function and constant usage.
//
//  Changes from C:
//  -Data type changes:
//     long is LongInt
//     double is Double
//     char * is PChar (array)
//     unsigned char * is TPByte (array)
//     long * is TPLongInt (array) or pass by reference
//     double * is TPDouble (array) or pass by reference
//  -AddRequest, ePut, eGet are overloadeded so that the pararmeter x1
//   can be acept either a LongInt or a Pointer.  For certain IOTypes, x1
//   can accept a pointer to a Char or Double array.
//
//  Version History:
//  0.1 - Initial release
//  0.2 - Updated constants and functions to UD driver version 2.67
//  0.3 - Updated constants and functions to UD driver version 3.25
//
//  support@labjack.com
//  March 28, 2011
//----------------------------------------------------------------------
//
unit LJUDDelphi;

interface

uses
  Winapi.Windows, Winapi.Messages, System.Classes, System.SysUtils, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, System.UITypes,
  VCLTee.TeEngine;


const
  SENSORSENS = 0.000025;     //25 uV / 5V / Torr   (from 5uV/V/Torr, using 5 V power supply)

  type
  LJ_HANDLE = Integer;
  LJ_ERROR = Integer;
  TPByte = ^Byte;            //Byte pointer
  TPLongInt = ^LongInt;      //LongInt pointer
  TPDouble = ^Double;        //Double pointer
   //types for use in Delphi LJ Class member function defs
  HND = Integer;
  IOTYPE = LongInt;
  CH = Double;
  VALUE = Double;
  XVAL = LongInt;
  USERDAT = Double;




(******************************************************************************
TLJAnalogIO Class Description
******************************************************************************)
type TLJAnalogIO = class
  public
    AioRange: Double;
    AioResolution: LongInt;
    AioSettleTime: LongInt;
    NumScans: Double;   //used for stream mode to store number of scans
    chStreamEnabled: Boolean;
    streamData: array[0..10050] of Double;
end;

(******************************************************************************
TLabJack Class Description
*****************************************************************************)
type TLabJack = class
    //private member data
    //private member methods

  public
    //public member data
    lngErrorCode: LJ_ERROR;
    lngHandle: LJ_HANDLE;
    lngIOType: LongInt;
    lngChannel: LongInt;
    err: array[0..254] of char;
    errNum: Integer;
    errStr: string;
    errIteration: Integer;
    localID: Double;      //ID of LabJack on bus (we can set this)
    hwVersion: Double;    //hardware version of LabJack
    serialNum: Double;     //LabJack SN
    fwVersion: Double;     //Firmware version
    doStream: Boolean;     //flag to tell stream process to stop
    U6Backlog: Double;
    drvBacklog: Double;
    //streamData: array[0..9999] of Double;
    AIO: array[0..1] of TLJAnalogIO;
    scanRate: Double; //number of scans/second that the LJ will do
    numScanCh: Integer; //number of scan channels that are active
    instrumentAmpGain: Integer;    //store the current gain setting of the EL1040 amp
    IntAmpGain: Integer;            //Internal LJ Amp gain setting
    torrMultiplier: Double;      //holds the calculated Torr unit multiplier
    //Constructor
    constructor Create;
    //public member methods
    procedure ErrorHandler(lngErrorcode: LJ_ERROR; lngIteration: LongInt);
    procedure InitLabJack;
   // procedure ConfigureStreamAN01;
    procedure PutBit(bitPos: Integer; Val: Integer);
    procedure GetBit(bitPos: Integer; var Val: Integer);
    procedure GetAnalogInput(Ch: Integer; var Val: VALUE);
    procedure GetAnalogGain(Ch: Integer);
    procedure SetAnalogGain(Ch: Integer; Gain: VALUE);
    procedure SetResolution(Ch: Integer; Res: Integer);
    procedure ConfigStream;
    procedure StopStream;
    procedure ProcessStream;
    procedure SetLJTickVal(ch: Integer; val: Double);
    procedure SetDtoAVal(ch: Integer; val: Double);
    function CalcTorrMult(): Double;
end;


//DLL FUNCTION DECLARATIONS
procedure Close() stdcall;
function ListAll(DeviceType: LongInt; ConnectionType: LongInt; var pNumFound: LongInt; pSerialNumbers: TPLongInt; pIDs: TPLongInt; pAddresses: TPDouble): LJ_ERROR stdcall;
function ListAllS(pDeviceType: PChar; pConnectionType: PChar; var pNumFound: LongInt; pSerialNumbers: TPLongInt; pIDs: TPLongInt; pAddresses: TPDouble): LJ_ERROR stdcall;

function OpenLabJack(DeviceType: LongInt; ConnectionType: LongInt; pAddress: PChar{const pAddress: array of Char}; FirstFound: LongInt; Var pHandle: LJ_HANDLE): LJ_ERROR stdcall;
function OpenLabJackS(pDeviceType: PChar; const pConnectionType: PChar; pAddress: PChar; FirstFound: LongInt; var pHandle: LJ_HANDLE): LJ_ERROR stdcall;

function AddRequest(LJ_HANDLE: LongInt; IOType: LongInt; Channel: LongInt; Value: Double; x1: LongInt; UserData: Double): LJ_ERROR stdcall; OverLoad;
function AddRequest(LJ_HANDLE: LongInt; IOType: LongInt; Channel: LongInt; Value: Double; x1: Pointer; UserData: Double): LJ_ERROR stdcall; OverLoad;
function AddRequestS(LJ_HANDLE: LongInt; pIOType: PChar; Channel: LongInt; Value: Double; x1: LongInt; UserData: Double): LJ_ERROR stdcall;
function AddRequestSS(LJ_HANDLE: LongInt; pIOType: PChar; pChannel: PChar; Value: Double; x1: LongInt; UserData: Double): LJ_ERROR stdcall;

function Go: LJ_ERROR; stdcall;
function GoOne(Handle: LJ_HANDLE): LJ_ERROR stdcall;

function eGet(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double; x1: LongInt): LJ_ERROR stdcall; Overload;
function eGet(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double; x1: Pointer): LJ_ERROR stdcall; Overload;
function eGetS(Handle: LJ_HANDLE; pIOType: PChar; Channel: LongInt; var pValue: Double; x1: LongInt): LJ_ERROR stdcall;
function eGetSS(Handle: LJ_HANDLE; pIOType: PChar; const spChannel: PChar; var pValue: Double; x1: LongInt): LJ_ERROR stdcall;

function ePut(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; Value: Double; x1: LongInt): LJ_ERROR stdcall; OverLoad;
function ePut(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; Value: Double; x1: Pointer): LJ_ERROR stdcall; OverLoad;
function ePutS(Handle: LJ_HANDLE; pIOType: PChar; Channel: LongInt; Value: Double; x1: LongInt): LJ_ERROR stdcall;
function ePutSS(Handle: LJ_HANDLE; pIOType: PChar; pChannel: PChar; Value: Double; x1: LongInt): LJ_ERROR stdcall;

function eGet_DblArray(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue, x1: TPDouble): LJ_ERROR stdcall;
function eGet_U8Array(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double; x1: TPByte): LJ_ERROR stdcall;
function eGetS_DblArray(Handle: LJ_HANDLE; pIOType: PChar; Channel: LongInt; var pValue: Double; x1: TPDouble): LJ_ERROR stdcall;
function eGetS_U8Array(Handle: LJ_HANDLE; pIOType: PChar; Channel: LongInt; var pValue: Double; x1: TPByte): LJ_ERROR stdcall;
function eGetSS_DblArray(Handle: LJ_HANDLE; pIOType: PChar; pChannel: PChar; var pValue: Double; x1: TPDouble): LJ_ERROR stdcall;
function eGetSS_U8Array(Handle: LJ_HANDLE; pIOType: PChar; pChannel: PChar; var pValue: Double; x1: TPByte): LJ_ERROR stdcall;

function GetResult(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double): LJ_ERROR stdcall;
function GetResultS(Handle: LJ_HANDLE; const pIOType: array of Char; Channel: LongInt; var pValue: Double): LJ_ERROR stdcall;
function GetResultSS(Handle: LJ_HANDLE; const pIOType: array of Char; const pChannel: array of Char; var pValue: Double): LJ_ERROR stdcall;

function GetFirstResult(Handle: LJ_HANDLE; var pIOType: LongInt; var pChannel: LongInt; var pValue: Double; var px1: LongInt; var pUserData: Double): LJ_ERROR stdcall;
function GetNextResult(Handle: LJ_HANDLE; var pIOType: LongInt; var pChannel: LongInt; var pValue: Double; var px1: LongInt; var pUserData: Double): LJ_ERROR stdcall;

function eAIN(Handle: LJ_HANDLE; ChannelP: LongInt; ChannelN: LongInt; var Voltage: Double; Range: LongInt; Resolution: LongInt; Settling: LongInt; Binary: LongInt; Reserved1: LongInt; Reserved2: LongInt): LJ_ERROR stdcall;
function eDAC(Handle: LJ_HANDLE;  Channel: LongInt; Voltage: Double; Binary: LongInt; Reserved1: LongInt; Reserved2: LongInt): LJ_ERROR stdcall;
function eDI(Handle: LJ_HANDLE; Channel: LongInt; var State: LongInt): LJ_ERROR stdcall;
function eDO(Handle: LJ_HANDLE; Channel: LongInt; State: LongInt): LJ_ERROR stdcall;
function eAddGoGet(Handle: LJ_HANDLE; NumRequests: LongInt; aIOTypes: TPLONGINT; aChannels: TPLONGINT; aValues: TPDOUBLE; ax1s: TPLONGINT; aRequestErrors: TPLONGINT; GoError: TPLONGINT; aResultErrors: TPLONGINT): LJ_ERROR stdcall; OverLoad;
function eAddGoGet(Handle: LJ_HANDLE; NumRequests: LongInt; aIOTypes: TPLONGINT; aChannels: TPLONGINT; aValues: TPDOUBLE; ax1s: Pointer; aRequestErrors: TPLONGINT; GoError: TPLONGINT; aResultErrors: TPLONGINT): LJ_ERROR stdcall; OverLoad;
function eTCConfig(Handle: LJ_HANDLE; aEnableTimers: TPLONGINT; aEnableCounters: TPLONGINT; TCPinOffset: LongInt; TimerClockBaseIndex: LongInt; TimerClockDivisor: LongInt; aTimerModes: TPLONGINT; aTimerValues: TPDOUBLE; Reserved1: LongInt; Reserved2: LongInt): LJ_ERROR stdcall;
function eTCValues(Handle: LJ_HANDLE; aReadTimers: TPLONGINT; aUpdateResetTimers: TPLONGINT; aReadCounters: TPLONGINT; aResetCounters: TPLONGINT; aTimerValues: TPDOUBLE; aCounterValues: TPDOUBLE; Reserved1: LongInt; Reserved2: LongInt): LJ_ERROR stdcall;

function eModbus(Handle: LJ_HANDLE; readwrite: LongInt; addr: LongInt; size: LongInt; value: TPByte): LJ_ERROR stdcall;

function ResetLabJack(Handle: LJ_HANDLE): LJ_ERROR stdcall;

function GetNextError(Handle: LJ_HANDLE; var pIOType: LongInt; var pChannel: LongInt): LJ_ERROR stdcall;
function GetStreamError(Handle: LJ_HANDLE): LJ_ERROR stdcall;

function DoubleToStringAddress(Number: Double; pString: PChar; HexDot: LongInt): LJ_ERROR stdcall;

function StringToDoubleAddress(pString: PChar; var pNumber: Double; HexDot: LongInt): LongInt stdcall;
function StringToConstant(pString: PChar): LongInt stdcall;

procedure ErrorToString(ErrorCode: LongInt; pString: PChar) stdcall;

function GetDriverVersion: Double stdcall;

function TCVoltsToTemp(TCType: LongInt; TCVolts: Double; CJTempK: Double; var pTCTempK: Double): LJ_ERROR stdcall;

function GetThreadID: Cardinal stdcall;

implementation

uses MerWFMain, LJConstants;

constructor TLabJack.Create;
var i: Integer;
begin
  for i := 0 to 1 do   //need to instantiate all objects used in TLabJack
    AIO[i]:= TLJAnalogIO.Create;
end;

(********************************************************************************
  TLabJact Method Implementations
*******************************************************************************)

(********************************************************************************
  ProcessStream: This method is called by a timer to read stream data from the
                 LJ UD driver, and copy it to the object storage array.
*******************************************************************************)
procedure TLabJack.ProcessStream;
var
i, k: Integer;
begin
 //Now read the data until user stops it.
  //frmMain.VSens0.Clear;   //clear data on chart from previous read
  //frmMain.VSens1.Clear;
  doStream := True;   //set to true
  AIO[0].NumScans := scanRate + 500;   //need to reset each iteration
  AIO[1].NumScans := scanRate + 500;
  for k := 0 to Length(AIO[0].streamData)-1 do  //stream data set by main form slider
      AIO[0].streamData[k] := 0;                 //clear the array
  for k := 0 to Length(AIO[1].streamData)-1 do  //stream data set by main form slider
      AIO[1].streamData[k] := 0;
  if AIO[0].chStreamEnabled then
    begin
      eGet(lngHandle, LJ_ioGET_STREAM_DATA, 0, AIO[0].NumScans, @AIO[0].streamData);
      //show num of scans actually read
      //frmMain.Memo1.Lines.Add(format('numScans read CH0: %.0f',[AIO[0].NumScans]));
    end;
  if AIO[1].chStreamEnabled then
    begin
      eGet(lngHandle, LJ_ioGET_STREAM_DATA, 1, AIO[1].NumScans, @AIO[1].streamData);
      //show num of scans actually read
      //frmMain.Memo1.Lines.Add(format('numScans read CH1: %.0f',[AIO[1].NumScans]));
    end;
     //get backlog (if any) for the LJ Buffer (U6 Backlog)
  eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_COMM, &U6Backlog, 0);
  //if U6BackLog > lastU6BackLog then
     //frmMain.Memo1.Lines.Add(format('U6 Backlog: %.0f   Iteration: %d',[U6Backlog, k]));
  //get backlog (if any) for the driver
  eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_UD, &DrvBacklog, 0);
  //frmMain.Memo1.Lines.Add(format('Drv Backlog: %.0f   Iteration: %d',[DrvBacklog, k]));
  Application.ProcessMessages;
end;


(********************************************************************************
  PutBit: This method writes the desired val (0 or 1) to the specified bit position.
*******************************************************************************)
procedure TLabJack.PutBit(bitPos: Integer; Val: Integer);
begin
  lngErrorCode := eDO(lngHandle, bitPos, Val);
  ErrorHandler(lngErrorCode, 0);
end;
(********************************************************************************
  GetBit: This method reads the current val (0 or 1) of the specified bit position.
*******************************************************************************)
procedure TLabJack.GetBit(bitPos: Integer; var Val: Integer);
begin
  lngErrorCode := eDI(lngHandle, bitPos, &Val);
  ErrorHandler(lngErrorCode, 0);
end;

(********************************************************************************
  ErrorHandler: This method determines if an error was detected while communicating
                with the LabJack, and reports if so.
*******************************************************************************)
procedure TLabJack.ErrorHandler(lngErrorcode: Integer; lngIteration: Integer);
begin
  if lngErrorcode <> LJE_NOERROR then
  begin
    //ErrorToString(lngErrorcode,@err);
    errNum:= lngErrorcode;
    errStr:= string(err);
    errIteration:= lngIteration;
    MessageDlg('Error while reading or writing to LabJack:'+#13+
                    'Error number: '+IntToStr(errNum)+#13+
                    'Error Message: '+errStr+#13+
                    'Iteration: '+IntToStr(errIteration),
                    mtError, [mbOK],0);   //need to decide if more selections should be added and how to handle them.
    if lngErrorcode > LJE_MIN_GROUP_ERROR then
      begin
        ShowMessage('Maximum error count exceeded. Application will now exit.');   //deterime if app should exit.
      end;
  end;
end;

(******************************************************************************
  InitLabJack: locates labjack, obtains information and saves to the labjack
                object for use by other functions.
*******************************************************************************)
procedure TLabJack.InitLabJack;
begin
  //initialize values
  lngHandle := 0;
  lngIOType := 0;
  lngChannel := 0;
  lngErrorCode :=  LJE_NOERROR;
  //try to find a labjack.
  try
   lngErrorcode:= OpenLabJack(LJ_dtU6, LJ_ctUSB, '3', 0, lngHandle);
   ErrorHandler(lngErrorCode, 0);
   except
     ShowMessage('Error encountered while attempting to open LabJack.');
   end;
   if lngErrorCode = LJE_NOERROR then
     begin
       //Get the labjack information
       lngErrorcode := eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chLOCALID, localID, 0);    //get the local id
       ErrorHandler(lngErrorCode, 0);
       lngErrorcode :=eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chHARDWARE_VERSION, hwVersion, 0);    //get the Hardware Version
       ErrorHandler(lngErrorCode, 0);
       lngErrorcode :=eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSERIAL_NUMBER, &serialNum, 0);    //get the Serial Number
       ErrorHandler(lngErrorCode, 0);
       lngErrorcode :=eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chFIRMWARE_VERSION, &fwVersion, 0);    //get the Firmware Version
       ErrorHandler(lngErrorCode, 0);
  end;
end;

(******************************************************************************
  GetAnalogGain: Reads the currently configured gain value for the channel
                 specified.
*******************************************************************************)
procedure TLabJack.GetAnalogGain(Ch: Integer);
begin
  lngErrorCode := eGet(lngHandle, LJ_ioGET_AIN_RANGE, Ch, AIO[Ch].AioRange, 0);
  ErrorHandler(lngErrorCode, 0);
end;

(******************************************************************************
  StopStream: Stops all active channels from streaming.
*******************************************************************************)
procedure TLabJack.StopStream;
begin
  lngErrorcode := ePut(lngHandle, LJ_ioSTOP_STREAM, 0,0,0);
end;

(******************************************************************************
  ConfigStream: Configures active channels for streaming,
  and begins stream mode.
*******************************************************************************)
procedure TLabJack.ConfigStream;
var
  lngChannel, lngTemp: LongInt;
  dblTemp, dblValue, lastDrvBackLog, lastU6BackLog: Double;
  k, i: Integer;
begin
  //Configure the scan rate
  lngErrorCode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_SCAN_FREQUENCY, scanRate, 0, 0);
  //Configure the buffer (scanrate * #channels * 2 seconds)
  lngErrorCode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_BUFFER_SIZE, (scanRate*numScanCh*2), 0, 0);
  //Configre the reads to retrieve the desired amount of data at a regular interval
  lngErrorCode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSTREAM_WAIT_MODE, LJ_swNONE, 0, 0);
  //Clear stream channels
  lngErrorCode := AddRequest(lngHandle, LJ_ioCLEAR_STREAM_CHANNELS, 0, 0, 0, 0);
  //define scan list
  if AIO[0].chStreamEnabled then
    lngErrorCode := AddRequest(lngHandle, LJ_ioADD_STREAM_CHANNEL, 0, 0, 0, 0);
  if AIO[1].chStreamEnabled then
    lngErrorCode := AddRequest(lngHandle, LJ_ioADD_STREAM_CHANNEL, 1, 0, 0, 0);
  //Execute list of requests
  lngErrorCode := GoOne(lngHandle);
  ErrorHandler(lngErrorcode, 0);
  //Get first result to check for errors
  lngErrorcode :=  GetFirstResult(lngHandle, lngIOType, LngChannel, dblValue, lngTemp, dblTemp);
  ErrorHandler(lngErrorcode, 0);
  //Now get the rest of the results to check for any errors that occured during set up.
  while lngErrorCode < LJE_MIN_GROUP_ERROR do
    begin
      lngErrorCode := GetNextResult(lngHandle, LngIOType, LngChannel, dblValue, LngTemp, dblTemp);
      if lngErrorCode <> LJE_NO_MORE_DATA_AVAILABLE then
        ErrorHandler(lngErrorcode, 0);
    end;
  //Finally, start the stream
  lngErrorcode := eGet(lngHandle, LJ_ioSTART_STREAM, 0, dblValue, 0);
  ErrorHandler(lngErrorcode, 0);
  frmMain.tmrStream.Enabled := True;      //start the timer, which will read the stream data
end;

(******************************************************************************
  SetAnalogGain: Set the gain value for the channel specified.
*******************************************************************************)
procedure TLabJack.SetAnalogGain(Ch: Integer; Gain: Double);
begin
  lngErrorCode := ePut(lngHandle, LJ_ioPUT_AIN_RANGE, Ch, Gain, 0);
  ErrorHandler(lngErrorCode, 0);
end;


(******************************************************************************
  SetDtoAVal: Set the D to A voltage to value and channel specified
*******************************************************************************)
procedure TLabJack.SetDtoAVal(ch: Integer; val: Double);
begin
  lngErrorCode := eDAC(lngHandle, ch, val,0,0,0);
  ErrorHandler(lngErrorCode, 0);
end;

(******************************************************************************
  SetLJTickVal: Set the LJTick DAC output to the voltage specified.
*******************************************************************************)
procedure TLabJack.SetLJTickVal(ch: Integer; val: Double);
begin
  lngErrorCode := ePut(lngHandle, LJ_ioPUT_CONFIG, LJ_chTDAC_SCL_PIN_NUM,2,0);   //config to ch 2
  ErrorHandler(lngErrorCode, 0);
  if ch = 0 then
    lngErrorCode := ePut(lngHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACA, val, 0) //set to val
    else if ch = 1 then
      lngErrorCode := ePut(lngHandle, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_UPDATE_DACB, val, 0); //set to val
  ErrorHandler(lngErrorCode, 0);
end;

(******************************************************************************
  SetAnalogResolution: Set the resolution value for the channel specified.
*******************************************************************************)
procedure TLabJack.SetResolution(Ch: Integer; Res: Integer);
begin
 lngErrorCode := AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chAIN_RESOLUTION, Res, 0, 0);
 ErrorHandler(lngErrorCode, 0);
end;

(******************************************************************************
  GetAnalogInput: Read the analog value from the channel specified.
*******************************************************************************)
procedure TLabJack.GetAnalogInput(Ch: Integer; var Val: VALUE);
begin
  lngErrorCode := eGet(lngHandle, LJ_ioGET_AIN, Ch, Val, 0);
  ErrorHandler(lngErrorCode, 0);
end;

(******************************************************************************
  CalcTorrMult: Convert voltage values read on the analog channels of the
                 LabJack to Torr (mmHg) values based on the current configuration
                 of both the internal and external amplifiers
*******************************************************************************)
function TLabJack.CalcTorrMult(): Double;
begin
  result := 1/(InstrumentAmpGain*IntAmpGain*SENSORSENS);
end;

//DLL FUNCTION IMPLEMENTATIONS
procedure Close; external 'labjackud.dll';
function ListAll; external 'labjackud.dll';
function ListAllS; external 'labjackud.dll';
function OpenLabJack; external 'labjackud.dll';
function OpenLabJackS; external 'labjackud.dll';
function AddRequest(LJ_HANDLE: LongInt; IOType: LongInt; Channel: LongInt; Value: Double; x1: LongInt; UserData: Double): LJ_ERROR stdcall; overload; external 'labjackud.dll';
function AddRequest(LJ_HANDLE: LongInt; IOType: LongInt; Channel: LongInt; Value: Double; x1: Pointer; UserData: Double): LJ_ERROR stdcall; overload; external 'labjackud.dll';
function AddRequestS; external 'labjackud.dll';
function AddRequestSS; external 'labjackud.dll';
function Go; external 'labjackud.dll';
function GoOne; external 'labjackud.dll';
function eGet(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double; x1: LongInt): LJ_ERROR stdcall; overload;external 'labjackud.dll';
function eGet(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; var pValue: Double; x1: Pointer): LJ_ERROR stdcall; overload;external 'labjackud.dll';
function eGetS; external 'labjackud.dll';
function eGetSS; external 'labjackud.dll';
function ePut(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; Value: Double; x1: LongInt): LJ_ERROR stdcall; overload;external 'labjackud.dll';
function ePut(Handle: LJ_HANDLE; IOType: LongInt; Channel: LongInt; Value: Double; x1: Pointer): LJ_ERROR stdcall; overload;external 'labjackud.dll';
function ePutS; external 'labjackud.dll';
function ePutSS; external 'labjackud.dll';
function eGet_DblArray; external 'labjackud.dll';
function eGet_U8Array; external 'labjackud.dll';
function eGetS_DblArray; external 'labjackud.dll';
function eGetS_U8Array; external 'labjackud.dll';
function eGetSS_DblArray; external 'labjackud.dll';
function eGetSS_U8Array; external 'labjackud.dll';
function GetResult; external 'labjackud.dll';
function GetResultS; external 'labjackud.dll';
function GetResultSS; external 'labjackud.dll';
function GetFirstResult; external 'labjackud.dll';
function GetNextResult; external 'labjackud.dll';
function eAIN; external 'labjackud.dll';
function eDAC; external 'labjackud.dll';
function eDI; external 'labjackud.dll';
function eDO; external 'labjackud.dll';
function eAddGoGet(Handle: LJ_HANDLE; NumRequests: LongInt; aIOTypes: TPLONGINT; aChannels: TPLONGINT; aValues: TPDOUBLE; ax1s: TPLONGINT; aRequestErrors: TPLONGINT; GoError: TPLONGINT; aResultErrors: TPLONGINT): LJ_ERROR stdcall; overload; external 'labjackud.dll';
function eAddGoGet(Handle: LJ_HANDLE; NumRequests: LongInt; aIOTypes: TPLONGINT; aChannels: TPLONGINT; aValues: TPDOUBLE; ax1s: Pointer; aRequestErrors: TPLONGINT; GoError: TPLONGINT; aResultErrors: TPLONGINT): LJ_ERROR stdcall; overload; external 'labjackud.dll';
function eTCConfig; external 'labjackud.dll';
function eTCValues; external 'labjackud.dll';
function eModbus; external 'labjackud.dll';
function ResetLabJack; external 'labjackud.dll';
function GetNextError; external 'labjackud.dll';
function GetStreamError; external 'labjackud.dll';
function DoubleToStringAddress; external 'labjackud.dll';
function StringToDoubleAddress; external 'labjackud.dll';
function StringToConstant; external 'labjackud.dll';
procedure ErrorToString; external 'labjackud.dll';
function GetDriverVersion; external 'labjackud.dll';
function TCVoltsToTemp; external 'labjackud.dll';
function GetThreadID; external 'labjackud.dll';


end.

